import Soldier from "./role/r1/Soldier";
import Shark from "./role/r2/Shark";
import Frog from "./role/r3/Frog";
import Octopus from "./role/r4/Octopus";

let roles = [];

export default class RoleManger {
	
    static createRole(data) {
        const ROLE$ = [Soldier, Shark, Frog, Octopus][parseInt(data.ho)-1];
        let role = new ROLE$(data);
        role.manger = this;
        roles.push(role);
        return role;
    }

    static destoryRole(role) {
        let index = roles.indexOf(role);
        roles.splice(index, 1);
        role.destory();
    }

    static getRoles() {
    	return roles;
    }

    static getRoleByUid(uid) {
    	return roles.find(role=> role.uid==uid);
    }

}